Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vendia/serverless-express

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vendia/serverless-express

This library enables you to utilize AWS Lambda and Amazon API Gateway to respond to web and API requests using your existing Node.js application framework.

  • 3.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
323K
decreased by-0.89%
Maintainers
4
Weekly downloads
 
Created

What is @vendia/serverless-express?

@vendia/serverless-express is an npm package that allows you to run an Express.js application on AWS Lambda and Amazon API Gateway. It simplifies the process of deploying Express.js applications in a serverless environment, providing a seamless integration with AWS services.

What are @vendia/serverless-express's main functionalities?

Basic Setup

This code demonstrates the basic setup of an Express.js application using @vendia/serverless-express. It creates a simple Express app with a single route and exports a Lambda handler.

const serverlessExpress = require('@vendia/serverless-express');
const app = require('express')();

app.get('/hello', (req, res) => {
  res.send('Hello, world!');
});

exports.handler = serverlessExpress({ app });

Custom Lambda Handler

This code shows how to create a custom Lambda handler using @vendia/serverless-express. It allows more control over the Lambda function's behavior by manually creating the server and proxying the event and context.

const serverlessExpress = require('@vendia/serverless-express');
const app = require('express')();

app.get('/hello', (req, res) => {
  res.send('Hello, world!');
});

const server = serverlessExpress.createServer(app);

exports.handler = (event, context) => {
  return serverlessExpress.proxy(server, event, context);
};

Middleware Integration

This example demonstrates how to integrate middleware into an Express.js application using @vendia/serverless-express. It includes JSON parsing and a custom logging middleware.

const serverlessExpress = require('@vendia/serverless-express');
const express = require('express');
const app = express();

app.use(express.json());
app.use((req, res, next) => {
  console.log('Request received:', req.method, req.path);
  next();
});

app.get('/hello', (req, res) => {
  res.send('Hello, world!');
});

exports.handler = serverlessExpress({ app });

Other packages similar to @vendia/serverless-express

Keywords

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc